//index.js
//获取应用实例
const app = getApp()

Page({
    data: {
        info: {}
    },

    onLoad: function (options) {
        this.getdata()
    },
    shangcheng: function () {
        wx.navigateToMiniProgram({
            appId: "wx83c03f5f6059cbd5"
        })
    },

    getdata: function () {
        const that = this
        wx.request({
            url: app.globalData.appurl + 'api/index/content', //首页数据接口
            data: {},
            method: "GET",
            // header: {
            //     'content-type': 'application/x-www-form-urlencoded' // 默认值
            // },
            success(res) {
                if (res.statusCode === 200) {
                    that.setData({
                        info: res.data.data
                    })
                }
            }
        })

    },
    dangriyoujia: function () {
        wx.navigateTo({
            url: "/pages/youjia/youjia"
        })
    },
    xianxingchaxun: function () {
        wx.navigateTo({
            url: "/pages/xianxing/xianxing"
        })
    },
    to_renzheng: function () {
        wx.showToast({
            title: '请先认证', // 标题
            icon: 'none', // 图标类型，默认success
            duration: 1500, // 提示窗停留时间，默认1500ms
            success: function () {
                wx.navigateTo({
                    url: "/pages/renzheng/renzheng"
                })
            }
        })
    },
    weizhangchaxun: function () {
        let that = this
        wx.getStorage({
            key: 'token',
            success: function (res) {
                that.setData({
                    token: res.data
                })
                // 获取用户认证信息
                wx.request({
                    url: app.globalData.appurl + 'api/user/get_user_renzheng',
                    data: {
                        token: res.data
                    },
                    method: "POST",
                    header: {

                    },
                    success(res) {
                        if (res.data.statusCode === 200) {
                            if (res.data.data.num === 6) {
                                wx.navigateTo({
                                    url: "/pages/weizhang/weizhang"
                                })
                            } else {
                                that.to_renzheng()
                            }

                        } else {
                            that.to_renzheng()
                        }
                    }
                })
            }
        })
    },
    onShow: function () {

    },

    sinfo: function (e) {
        var goods_id = e.currentTarget.dataset.goods_id
        wx.navigateTo({
            url: "/pages/fuwu/info/info?goods_id=" + goods_id
        })
    }
})